home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 1
/
Nebula One.iso
/
Mail
/
pine3.92
/
pine
/
osdep
/
fnexpand.os2
< prev
next >
Wrap
Text File
|
1996-03-14
|
896b
|
34 lines
#line 2 "osdep/fnexpand.os2"
/*----------------------------------------------------------------------
Expand the ~ in a file ala the csh (as home directory)
Args: buf -- The filename to expand (nothing happens unless begins with ~)
len -- The length of the buffer passed in (expansion is in place)
Result: Expanded string is returned using same storage as passed in.
If expansion fails, NULL is returned
----*/
char *
fnexpand(buf, len)
char *buf;
int len;
{
register char *x,*y;
char * home;
char name[20];
char * gethomedir();
if(*buf == '~') {
home=gethomedir();
for(x = buf+1, y = name; *x != '/' && *x != '\0'; *y++ = *x++);
*y = '\0';
if(strlen(home) + strlen(buf) > len) {
return((char *)NULL);
}
rplstr(buf, x - buf, home);
}
return(len ? buf : (char *)NULL);
}